package cn.iocoder.yudao.module.tms.controller.admin.bandinfo;

import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.tms.controller.admin.bandinfo.vo.BandInfoPageReqVO;
import cn.iocoder.yudao.module.tms.controller.admin.bandinfo.vo.BandInfoRespVO;
import cn.iocoder.yudao.module.tms.controller.admin.bandinfo.vo.BandInfoSaveReqVO;
import cn.iocoder.yudao.module.tms.dal.dataobject.bandinfo.BandInfoDO;
import cn.iocoder.yudao.module.tms.service.bandinfo.BandInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.http.HttpStatus;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;

import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 公司band信息")
@RestController
@RequestMapping("/tms/band-info")
@Validated
public class BandInfoController {

    @Resource
    private BandInfoService bandInfoService;

    @PostMapping("/create")
    @Operation(summary = "创建公司band信息")
    @PreAuthorize("@ss.hasPermission('tms:band-info:create')")
    public CommonResult<Long> createBandInfo(@Valid @RequestBody BandInfoSaveReqVO createReqVO) {
        return success(bandInfoService.createBandInfo(createReqVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新公司band信息")
    @PreAuthorize("@ss.hasPermission('tms:band-info:update')")
    public CommonResult<Boolean> updateBandInfo(@Valid @RequestBody BandInfoSaveReqVO updateReqVO) {
        bandInfoService.updateBandInfo(updateReqVO);
        return success(true);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "删除公司band信息")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('tms:band-info:delete')")
    public CommonResult<Boolean> deleteBandInfo(@RequestParam("id") Long id) {
        bandInfoService.deleteBandInfo(id);
        return success(true);
    }

    @GetMapping("/get")
    @Operation(summary = "获得公司band信息")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('tms:band-info:query')")
    public CommonResult<BandInfoRespVO> getBandInfo(@RequestParam("id") Long id) {
        BandInfoDO bandInfo = bandInfoService.getBandInfo(id);
        return success(BeanUtils.toBean(bandInfo, BandInfoRespVO.class));
    }

    @GetMapping("/page")
    @Operation(summary = "获得公司band信息分页")
    @PreAuthorize("@ss.hasPermission('tms:band-info:query')")
    public CommonResult<PageResult<BandInfoRespVO>> getBandInfoPage(@Valid BandInfoPageReqVO pageReqVO) {
        PageResult<BandInfoDO> pageResult = bandInfoService.getBandInfoPage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, BandInfoRespVO.class));
    }

}